* commands that must be installed: omegacoef drdid
* open "sf_replication_data"

* outcome variable: justification of violence
* students throw stones at the police (f05_07)
gen piedras=f05_07 
replace piedras=. if f05_07==-999
replace piedras=. if f05_07==-888

* treatment variables: proximity to at least one protest (1) vs none (0)
* with active policing
* 2 km
* dichotomize at 6 weeks
gen represion_6w_2k=.
replace represion_6w_2k=0 if represion_dummy_6w_2k==0
replace represion_6w_2k=1 if represion_dummy_6w_2k>0
replace represion_6w_2k=. if represion_dummy_6w_2k==.
* dichotomize at 4 weeks
gen represion_4w_2k=.
replace represion_4w_2k=0 if represion_dummy_4w_2k==0
replace represion_4w_2k=1 if represion_dummy_4w_2k>0
replace represion_4w_2k=. if represion_dummy_4w_2k==.
* dichotomize at 2 weeks
gen represion_2w_2k=.
replace represion_2w_2k=0 if represion_dummy_2w_2k==0
replace represion_2w_2k=1 if represion_dummy_2w_2k>0
replace represion_2w_2k=. if represion_dummy_2w_2k==.
* 4 km
* dichotomize at 6 weeks
gen represion_6w_4k=.
replace represion_6w_4k=0 if represion_dummy_6w_4k==0
replace represion_6w_4k=1 if represion_dummy_6w_4k>0
replace represion_6w_4k=. if represion_dummy_6w_4k==.
* dichotomize at 4 weeks
gen represion_4w_4k=.
replace represion_4w_4k=0 if represion_dummy_4w_4k==0
replace represion_4w_4k=1 if represion_dummy_4w_4k>0
replace represion_4w_4k=. if represion_dummy_4w_4k==.
* dichotomize at 2 weeks
gen represion_2w_4k=.
replace represion_2w_4k=0 if represion_dummy_2w_4k==0
replace represion_2w_4k=1 if represion_dummy_2w_4k>0
replace represion_2w_4k=. if represion_dummy_2w_4k==.
* 6 km
* dichotomize at 6 weeks
gen represion_6w_6k=.
replace represion_6w_6k=0 if represion_dummy_6==0
replace represion_6w_6k=1 if represion_dummy_6>0
replace represion_6w_6k=. if represion_dummy_6==.
* dichotomize at 4 weeks
gen represion_4w_6k=.
replace represion_4w_6k=0 if represion_dummy_4==0
replace represion_4w_6k=1 if represion_dummy_4>0
replace represion_4w_6k=. if represion_dummy_4==.
* dichotomize at 2 weeks
gen represion_2w_6k=.
replace represion_2w_6k=0 if represion_dummy_2==0
replace represion_2w_6k=1 if represion_dummy_2>0
replace represion_2w_6k=. if represion_dummy_2==.

* without active policing
* 2km
* dichotomize at 6 weeks
gen sin_represion_6w_2k=.
replace sin_represion_6w_2k=0 if sin_represion_dummy_6w_2k==0
replace sin_represion_6w_2k=1 if sin_represion_dummy_6w_2k>0
replace sin_represion_6w_2k=. if sin_represion_dummy_6w_2k==.
* dichotomize at 4 weeks
gen sin_represion_4w_2k=.
replace sin_represion_4w_2k=0 if sin_represion_dummy_4w_2k==0
replace sin_represion_4w_2k=1 if sin_represion_dummy_4w_2k>0
replace sin_represion_4w_2k=. if sin_represion_dummy_4w_2k==.
* dichotomize at 2 weeks
gen sin_represion_2w_2k=.
replace sin_represion_2w_2k=0 if sin_represion_dummy_2w_2k==0
replace sin_represion_2w_2k=1 if sin_represion_dummy_2w_2k>0
replace sin_represion_2w_2k=. if sin_represion_dummy_2w_2k==.
* 4 km
* dichotomize at 6 weeks
gen sin_represion_6w_4k=.
replace sin_represion_6w_4k=0 if sin_represion_dummy_6w_4k==0
replace sin_represion_6w_4k=1 if sin_represion_dummy_6w_4k>0
replace sin_represion_6w_4k=. if sin_represion_dummy_6w_4k==.
* dichotomize at 4 weeks
gen sin_represion_4w_4k=.
replace sin_represion_4w_4k=0 if sin_represion_dummy_4w_4k==0
replace sin_represion_4w_4k=1 if sin_represion_dummy_4w_4k>0
replace sin_represion_4w_4k=. if sin_represion_dummy_4w_4k==.
* dichotomize at 2 weeks
gen sin_represion_2w_4k=.
replace sin_represion_2w_4k=0 if sin_represion_dummy_2w_4k==0
replace sin_represion_2w_4k=1 if sin_represion_dummy_2w_4k>0
replace sin_represion_2w_4k=. if sin_represion_dummy_2w_4k==.
* 6 km
* dichotomize at 6 weeks
gen sin_represion_6w_6k=.
replace sin_represion_6w_6k=0 if sin_represion_6==0
replace sin_represion_6w_6k=1 if sin_represion_6>0
replace sin_represion_6w_6k=. if sin_represion_6==.
* dichotomize at 6 weeks
gen sin_represion_4w_6k=.
replace sin_represion_4w_6k=0 if sin_represion_4==0
replace sin_represion_4w_6k=1 if sin_represion_4>0
replace sin_represion_4w_6k=. if sin_represion_4==.
* dichotomize at 2 weeks
gen sin_represion_2w_6k=.
replace sin_represion_2w_6k=0 if sin_represion_2==0
replace sin_represion_2w_6k=1 if sin_represion_2>0
replace sin_represion_2w_6k=. if sin_represion_2==.


* propensity variables for protest occurrence (controls): 
* at the census zone level
* population density per km² in the census tract: densidad_pob_km2
gen densidad=densidad_pob_km2
replace densidad=. if densidad_pob_km2==-995

* number of people aged 15 to 24 in the census zone: jovenes
gen joven=jovenes
replace joven=. if joven==-995

* average years of schooling in the census zone: escolaridad
gen mescolaridad=escolaridad
replace mescolaridad=. if escolaridad==-995

* % of dwellings in precarious condition: viv_precaria
* number of precarious dwellings
gen nprecaria=viv_precaria
replace nprecaria=. if viv_precaria==-995

* total number of dwellings
gen nviviendas=viviendas
replace nviviendas=. if viviendas==-995

* % of precarious dwellings
gen precaria=(nprecaria*100)/nviviendas
* population size (number of inhabitants) in the census zone
gen size=hbtes
replace size=. if hbtes==-995

* % of women  
* number of women
gen nfemale=mujer
replace nfemale=. if mujer==-995
gen female=(nfemale*100)/size

* individual level  
* Actively follows political news in media such as TV, radio, newspapers, or the internet: c14_02
gen media=c14_02
replace media=. if c14_02==-999
replace media=. if c14_02==-888

* gender: m0_sexo
gen gender=m0_sexo 

* age: m0_edad
gen age= m0_edad

* educational level: m01, converted to average years of schooling based on CASEN survey
gen educ=.
* no formal education (1): 0 years
replace educ=0 if m01==1
* incomplete primary education (2): 4.29768 years
replace educ=4.29768 if m01==2
* completed primary education (3): 7.490834 years
replace educ=7.490834 if m01==3
* incomplete secondary education (4): 9.728731 years
replace educ=9.728731 if m01==4
* completed secondary education (5): 12 years
replace educ=12 if m01==5
* incomplete technical tertiary education (6): 13.89423 years
replace educ=13.89423 if m01==6
* completed technical tertiary education (7): 14.81908 years
replace educ=14.81908 if m01==7
* incomplete university education (8): 14.89103 years
replace educ=14.89103 if m01==8
* completed university education (9): 16.93914 years
replace educ=16.93914 if m01==9
* postgraduate studies (10): 18.50766 years
replace educ=18.50766 if m01==10

* participated in a peaceful protest in the previous year (dummy)
gen protesta2018=.
replace protesta2018=0 if c08_02==1
replace protesta2018=1 if c08_02>=2

* most valued social movement: student, other, or none
gen movement=2
replace movement=1 if c20==1
replace movement=0 if c20==12
replace movement=. if c20==-999
replace movement=. if c20==-888

* trust in police: c05_03
gen conf_carab=c05_03
replace conf_carab=. if c05_03==-888
replace conf_carab=. if c05_03==-999 

* interpersonal trust
* people can be trusted: c02
gen trust=c02
replace trust=. if c02==-888
replace trust=. if c02==-999

* social dominance orientation c18_01 to c18_03
* c18_01: ideal society requires some groups to be in superior and inferior positions
gen position=c18_01
replace position=. if c18_01==-888
replace position=. if c18_01==-999
* c18_02: Some groups of people are just inferior
gen inferior=c18_02
replace inferior=. if c18_02==-888
replace inferior=. if c18_02==-999
* c18_03: we should do everything possible to equal different groups' conditions
gen equal=c18_03
replace equal=. if c18_03==-888
replace equal=. if c18_03==-999
* check alpha and create scale
alpha position inferior equal, item
* alpha is low ( 0.4736), it would be higher if one the second and third variables were left (0.7503)
alpha inferior equal, item gen(dominance)


* authoritarian attitudes (RWA): c18_04 to c18_07  
* c18_04: More than rights, we need a strong government
gen firme=c18_04
replace firme=. if c18_04==-999
replace firme=. if c18_04==-888
* c18_05: The country needs a strong leader
gen fuerte=c18_05
replace fuerte=. if c18_05==-999
replace fuerte=. if c18_05==-888
* c18_06: Obedience and respect are the most important things children should learn
gen obediencia=c18_06
replace obediencia=. if c18_06==-999
replace obediencia=. if c18_06==-888
* c18_07: Obedience and discipline are key to a good life
gen disciplina=c18_07
replace disciplina=. if c18_07==-999
replace disciplina=. if c18_07==-888
* aggregate and display Cronbach's alpha (0.8324) and McDonald's omega (0.8335)
alpha firme fuerte obediencia disciplina, item gen(authoritarian)
omegacoef firme fuerte obediencia disciplina

* moderator (motivated reasoning)  
* ideology
gen ideo2= .
* right=1 (6-10)
replace ideo2=1 if c15==6
replace ideo2=1 if c15==7
replace ideo2=1 if c15==8
replace ideo2=1 if c15==9
replace ideo2=1 if c15==10
* center=2 (5)
replace ideo2=2 if c15==5
* left=3 (0-4)
replace ideo2=3 if c15==0
replace ideo2=3 if c15==1
replace ideo2=3 if c15==2
replace ideo2=3 if c15==3
replace ideo2=3 if c15==4
* independent/none=4 (11-12)
replace ideo2=4 if c15==11
replace ideo2=4 if c15==12
label define ideo2l 1 "Right" 2 "Center" 3 "Left" 4 "Independent/None"
label values ideo2 ideo2l 

*************************************************************
**** Doubly Robust Difference-in-Differences Regressions ****
*************************************************************

* effect of protests with repression on justification of throwing stones  (Figure 1 in manuscript, Table A1 in Appendix)
* 2 km  
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_2w_2k) drimp
outreg2 using tablea11.xls, replace tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r1
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_4w_2k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r2
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_6w_2k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r3
* 4km
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_2w_4k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r4
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_4w_4k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r5
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_6w_4k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r6
* 6km
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r7
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_4w_6k) drimp 
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r8
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_6w_6k) drimp
outreg2 using tablea11.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r9
* Coefplot 
coefplot (r1, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r2, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r3, label(8 weeks) msymbol(U) color(white) pstyle(p3)) (r4, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r5, label (4 weeks) msymbol(T) color(white) pstyle(p2)) (r6, label(8 weeks) msymbol(U) color(white) pstyle(p3)) (r7, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r8, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r9, label(8 weeks) msymbol(U) color(white)pstyle(p3)), xline(0) drop(_cons) name(figure_4, replace) levels(99 95 90) legend(order(1 "99" 2 "95" 3 "90")) ciopts(lwidth(*1 *3 *6)) mlabel mlabposition(4) mlabgap(*2) ylabel(1 "2 weeks 2 kms" 2 "4 weeks 2 kms" 3 "6 weeks 2 kms"  4 "2 weeks 4 kms" 5 "4 weeks 4 kms" 6 "6 weeks 4 kms" 7 "2 weeks 6 kms" 8 "4 weeks 6 kms" 9 "6 weeks 6 kms", valuelabel angle(0) labsize(small)) legend(title("Confidence Intervals")) plotregion(margin(b+5))

* Effect by ideology. 6 km, 2 weeks (Table 1 in manuscript)
* IPW and regression adjustment (sipwra) does not run in the Right subgroup
* Right (n=522)
* Right (dripw)
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==1 & wave==3 | ideo2==1 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) dripw 
outreg2 using table1.xls, replace tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Right (drimp) 
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==1 & wave==3 | ideo2==1 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) drimp 
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Right (reg) 
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==1 & wave==3 | ideo2==1 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) reg 
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Right (ipw) 
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==1 & wave==3 | ideo2==1 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) ipw 
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Right (stdipw) 
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==1 & wave==3 | ideo2==1 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) stdipw 
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Center n=714
* Center (all)
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==2 & wave==3 | ideo2==2 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) all
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Left (n=798)
* Left (all)
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==3 & wave==3 | ideo2==3 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) all
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Nonideologue (n=1,130)
* Nonideologue (all) 
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust if ideo2==4 & wave==3 | ideo2==4 & wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) all 
outreg2 using table1.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)

* Placebo tests: compare change from 2017 to 2018  (Figure 6 in manuscript, Table A2 in Appendix)
* 2 km  
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_2w_2k) drimp
outreg2 using tablea2.xls, replace tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r10
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_4w_2k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r11
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_6w_2k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r12
* 4km
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_2w_4k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r13
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_4w_4k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r14
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_6w_4k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r15
* 6km
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_2w_6k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r16
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_4w_6k) drimp 
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r17
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if  wave==2 | wave==3, ivar(idencuesta) time(ola) tr(represion_6w_6k) drimp
outreg2 using tablea2.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
estimates store r18
* Coefplot
coefplot (r10, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r11, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r12, label(8 weeks) msymbol(U) color(white) pstyle(p3)) (r13, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r14, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r15, label(8 weeks) msymbol(U) color(white) pstyle(p3)) (r16, label(2 weeks) msymbol(S) color(white) pstyle(p1))(r17, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r18, label(8 weeks) msymbol(U) color(white)pstyle(p3)), xline(0) drop(_cons) name(figure_6, replace) levels(99 95 90) legend(order(1 "99" 2 "95" 3 "90")) ciopts(lwidth(*1 *3 *6)) mlabel mlabposition(4) mlabgap(*2) ylabel(1 "2 weeks 2 kms" 2 "4 weeks 2 kms" 3 "6 weeks 2 kms"  4 "2 weeks 4 kms" 5 "4 weeks 4 kms" 6 "6 weeks 4 kms" 7 "2 weeks 6 kms" 8 "4 weeks 6 kms" 9 "6 weeks 6 kms", valuelabel angle(0) labsize(small)) legend(title("Confidence Intervals")) plotregion(margin(b+5))

* Fffect of protests without active policing on outcome (Figure 7 in manuscript)  
* 2 km  
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_2w_2k) drimp
estimates store r19
outreg2 using tablea12.xls, replace tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_4w_2k) drimp
estimates store r20
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_6w_2k) drimp
estimates store r21
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 4km
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_2w_4k) drimp
estimates store r22
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_4w_4k) drimp
estimates store r23
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_6w_4k) drimp
estimates store r24
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 6km
* 2 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_2w_6k) drimp
estimates store r25
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 4 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_4w_6k) drimp
estimates store r26
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 6 weeks
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(sin_represion_6w_6k) drimp
estimates store r27
outreg2 using tablea12.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Coefplot 
coefplot (r19, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r20, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r21, label(8 weeks) msymbol(U) color(white) pstyle(p3)) (r22, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r23, label (4 weeks) msymbol(T) color(white) pstyle(p2)) (r24, label(8 weeks) msymbol(U) color(white) pstyle(p3)) (r25, label(2 weeks) msymbol(S) color(white) pstyle(p1)) (r26, label(4 weeks) msymbol(T) color(white) pstyle(p2)) (r27, label(8 weeks) msymbol(U) color(white)pstyle(p3)), xline(0) drop(_cons) name(figure_7, replace) levels(99 95 90) legend(order(1 "99" 2 "95" 3 "90")) ciopts(lwidth(*1 *3 *6)) mlabel mlabposition(4) mlabgap(*2) ylabel(1 "2 weeks 2 kms" 2 "4 weeks 2 kms" 3 "6 weeks 2 kms"  4 "2 weeks 4 kms" 5 "4 weeks 4 kms" 6 "6 weeks 4 kms" 7 "2 weeks 6 kms" 8 "4 weeks 6 kms" 9 "6 weeks 6 kms", valuelabel angle(0) labsize(small)) legend(title("Confidence Intervals")) plotregion(margin(b+5))

* Effect of using alternative treatment definitions: many protests  at 6 km, 2 weeks (Figure A1 in Appendix)
summarize represion_dummy_2, detail
* 90th percentile  
gen represion_2w_6k_90=.
replace represion_2w_6k_90=0 if represion_dummy_2==0
replace represion_2w_6k_90=1 if represion_dummy_2>3
replace represion_2w_6k_90=. if represion_dummy_2==.
tab represion_2w_6k_90
* 90th percentile reaches up to 3 protests, so it helps distinguish this from the original treatment definition
* 9.67% of the sample was treated
* 95th percentile  
* 95th percentile reaches up to 5 protests
gen represion_2w_6k_95=.
replace represion_2w_6k_95=0 if represion_dummy_2==0
replace represion_2w_6k_95=1 if represion_dummy_2>5
replace represion_2w_6k_95=. if represion_dummy_2==.
tab represion_2w_6k_95
* 4.75% of the sample was treated
* original definition (1 or more protests)
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k) drimp
estimates store r30
outreg2 using tablea4.xls, replace tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 90th percentile (more than three protests)
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k_90) drimp
estimates store r31
outreg2 using tablea4.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* 95th percentile (more than five protests)
drdid piedras c.densidad c.joven c.mescolaridad c.precaria c.female i.media i.gender c.age c.educ i.movement i.protesta2018 i.conf_carab c.authoritarian c.dom i.trust i.ideo if wave==3 | wave==4, ivar(idencuesta) time(ola) tr(represion_2w_6k_95) drimp
estimates store r32
outreg2 using tablea4.xls, append tex alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, †)
* Coefplot
coefplot (r30, label(1 or more protests (original)) msymbol(S) color(white) pstyle(p1)) (r31, label(More than 3 protests (90th percentile)) msymbol(T) color(white) pstyle(p2)) (r32, label(More than 5 protests (95th percentile)) msymbol(U) color(white) pstyle(p3)), xline(0) drop(_cons) name(figure_a1, replace) levels(99 95 90) legend(order(1 "99" 2 "95" 3 "90")) ciopts(lwidth(*1 *3 *6)) mlabel mlabposition(4) mlabgap(*2) ylabel(1 "1 or more protests (original)" 2 "More than 3 protests (90th percentile)" 3 "More tjan 5 protests (95th percentile)",  valuelabel angle(0) labsize(small)) legend(title("Confidence Intervals")) 
